
* "A Two-Level Theory of Presidential Instability"
* Anibal Perez-Linan
* Latin American Politics and Society (2014)

*cd "C:\Users\Anibal\Documents\1_Research\Research in Progress\Papers in Progress\Mexico\LAPS\Replication"

use "1_LAPS_data.dta", clear

xtset pcode2 year

* Operational definitions 

gen sthreat = 0
replace sthreat = 1 if  ((prot02==1 | prot04==1 | prot05==1) & (prot03==1 | prot06==1))
label var sthreat "Broad protest (threat)"

gen lshield = 0
replace lshield = 1 if  (((p_h > .5 & p_h !=.) | (p_s > .5 & p_s !=.)) & pres04==0 )
label var lshield "Legislative shield"

gen config4 = sthreat*lshield
label var config4 "Broad protest*Shield"

* Table 3

xtlogit y         lshield         milint prscan1 ppbi g inf  
estimates store m31

xtlogit y sthreat lshield         milint prscan1 ppbi g inf  
estimates store m32

xtlogit y sthreat lshield config4 milint prscan1 ppbi g inf  
estimates store m33

xml_tab m31 m32 m33, format((S2100) (N2203)) save("Table3.xls") below stats(N) ///
        keep(sthreat lshield config4 milint prscan1 ppbi g inf _cons) sheet("Table_3") stars(* 0.1 ** 0.05) font("Times New Roman" 12) replace  

* Figure 2

set level 97.5         /* Sidak correction */
lincom sthreat         /* Effect of change from configuration 1 to 3 */
lincom sthreat+config4 /* Effect of change from configuration 2 to 4 */
		
* Figure 3

xtlogit y i.sthreat i.lshield i.sthreat#i.lshield milint prscan1 ppbi g inf 
*margins, over(lshield) dydx(sthreat) predict(xb) /* Verify conditonal effect */
set level 95
margins i.sthreat#i.lshield, predict(pu0) /* Predicted probabilities using observed-value approach */


* Jackknife test for model 3.3 (removing one country at a time)

jackknife, cluster(cowcode): xtlogit y sthreat lshield config4 milint prscan1 ppbi g inf


